Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

225
Visualizações
Delete a field from Firebase Firestore where the field/key has a period/punctuation (".") - modular v9 JavaScript SDK

This question is for a React Native Expo mobile App if that matters.

I have a flat database object. Using the documentation as an example:

  • https://firebase.google.com/docs/firestore/manage-data/delete-data

I have added a field/key called "example.com" with some arbitrary value. The object then looks like this:

{
capital: "words",
location: "other words",
"example.com": "more words"
}

I want to delete the key "example.com" key from the database, and I am using pretty much the same code as in the example from the documentation.

const cityRef = doc(db, "cities", "BJ");
const payload = {
    "example.com": deleteField(),
};
await updateDoc(cityRef, payload);

This does not delete the "example.com" key. I understand that this attempts to delete the "com" key from the "example" object within the main database document, which is not what I want, but I do not understand how to rework this code to treat the entire string as a key.

I have looked at some similar questions here on SO(links at the bottom) that came to the conclusion that they had to use FieldPath, but the syntax is outdated, and no longer works on the current version of Firestore(or at least I can not find the documentation for FieldPath for the version I am using, linked above).

And tips on how to get this working (deleting a field with a period) would be appreciated.

Link to similar problems:

  • Cannot update/delete Firestore field with "period" in the name
  • Cannot Delete Fields with Period in Key Name
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You still need to use FieldPath, but the API is different in the new v9 module SDK. You can see FieldPath in the API docs. Just import it along with any other functions that you use from the Firestore SDK.

I haven't used it myself, but based on the linked docs, my guess is that it works like this:

import { updateDoc, deleteField, FieldPath } from "firebase/firestore";
...
updateDoc(cityRef, new FieldPath("example.com"), deleteField());
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda